package Player;

import Card.*;
import Ioperate.IplayCard;

public class Player implements IplayCard {
    //成员
    public int Hp;
    private Card[] cards = new Card[]{new KillCard(),new DodgeCard(),new SkilCard()};
    public String pyName;
    //构造方法
    public Player(int Hp) {
        this.Hp = Hp;
    }
    public Player() {

    }
    //

    //实现出牌操作接口
    public int playCard(int index) {
        this.cards[index-1].num--;
        System.out.print(this.pyName+"出了一张"+this.cards[index-1].cardName);
        return this.cards[index-1].harm;
    }
    //实现接收牌操作接口
    public String receiveCard(int index) {
        return this.cards[index-1].cardName;
    }

    //显示玩家信息
    public void display() {
        System.out.println("   ^^^^^^^^^"+this.pyName+"信息^^^^^^^^^");
        System.out.println("   ^       ("+this.pyName+")           ^");
        System.out.println("   ^      (生命值"+this.Hp+")         ^");
        System.out.println("   ^       (牌数"+this.cardsNum()+")          ^");
        System.out.println("   ^^^^^^^^^^^^^^^^^^^^^^^^^");
    }

    //获取牌数
    public int cardsNum() {
        return this.cards[0].num+this.cards[1].num+this.cards[2].num;
    }
    //
    //重写toString
    @Override
    public String toString() {
        return "{ ["+this.cards[0].cardName+",伤害"+this.cards[0].harm+",数量"+this.cards[0].num+"] " +
                "["+this.cards[1].cardName+",伤害"+this.cards[1].harm+",数量"+this.cards[1].num+"] " +
                "["+this.cards[2].cardName+",伤害"+this.cards[2].harm+",数量"+this.cards[2].num+"] }";
    }
}
